package loop;

import org.testng.annotations.Test;

import java.util.Scanner;

/**
 * @author zhang peipei
 */
public class Break1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

//        int N = sc.nextInt();  // < 1000000
        int max = 0;
        for(int i = 1; i <= 100; i++) {
            int temp = i;
            while(temp != 1) {
                if(temp % 2 != 0) {
                    temp = (temp * 3) + 1;
                    max = Math.max(temp, max);
                }else {
                    temp /= 2;
                }
            }
        }
        System.out.println(max);

        sc.close();
    }


    @Test
    private void t4() {

        int n = 0;
        int count = 0;
        // 偶数除以2，奇数乘以3 加上 1
        for (int i = 1; i <= 100; i++) {
            int res = res(i, 1);
            if (res > count) {
                n = i;
                count = res;
            }
        }

        System.out.println(n + ", " + count);
    }

    private static int res(int n, int num) {

        int res;
        if (n % 2 == 0) {
            res = n / 2;
        } else {
            res = n * 3 + 1;
        }

        if (res != 1) {
            return res(res, num + 1);
        }

        return num;
    }


    @Test
    private void t1() {

        for (int i = 0; i < 5; i++) {
            switch (i) {
                case 2:
                    System.out.println(i);
                    break;
                case 4:
                    System.out.println(i);
                    break;
                default:
            }
        }
    }
}
